<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 求100以内所有偶数的和
        // 1-100之间的数字，判断如果是偶数再把i累加到sum上
        var sum = 0;//记录和
        for (var i = 0; i < 100; i++) {
            if (i % 2 === 0) sum = sum + i;
        }
        console.log(sum);
    </script>

</body>

</html>